*************************************************************************************
*DID at the department level: centralized cadaster progress --> per capita land tax *
*************************************************************************************

cd "~"

use ".\data\data_deplevel.dta", clear

*Quinquennial data
gen year5 = floor(year/5)*5 
keep if year==year5 & year5>=1800 & year5<1850

*For continuous treatment: 10% increments
gen treat = round(areacadshare*10)
gen treatcent = round(areacadcentshare*10)
gen treatloc = round(areacadlocshare*10)

*For binary treatment: median
gen treatcentmed = (areacadcentshare>.3)

*Controls x time dummies
tab year5, gen(year_)  // Creates year_1, year_2, year_3, etc.
foreach var of varlist lrugged lwheat ldistpref ldistparis ldistroads ldistforest lnbalien {
    forval t = 1/`=r(r)' {
        gen `var'_X_year`t' = `var' * year_`t'
    }
}

** Continuous treatment ***	
did_multiplegt lcontfoncpop code_dept year5 treatcent, cluster(code_dept) controls(lshareurban rebel lnbank lnbatciv *_X_*) robust_dynamic dynamic(5) placebo(3) threshold_stable_treatment(1) save(".\stata outputs\lcontfoncpop_treatcent")
did_multiplegt lcontfoncpop code_dept year5 treatcent, cluster(code_dept ) robust_dynamic dynamic(5) placebo(3) threshold_stable_treatment(1) save(".\stata outputs\lcontfoncpop_treatcent_nocont")

*** Binary treatment ***
did_multiplegt_dyn lcontfoncpop code_dept year5 treatcentmed, cluster(code_dept) controls(lshareurban rebel lnbank lnbatciv *_X_*) effects(10) placebo(3)  save(".\stata outputs\lcontfoncpop_treatcentmed")
did_multiplegt_dyn lcontfoncpop code_dept year5 treatcentmed, cluster(code_dept)  effects(10) placebo(3)  save(".\stata outputs\lcontfoncpop_treatcentmed_nocont")



